package com.hbpu.encap.thread;

public class MyThread implements Runnable {
    private static int total = 10000;

    @Override
    public void run() {

        while (true) {
            synchronized (this) {
                if (total == 0) {
                    break;
                }
                System.out.println("线程：" + Thread.currentThread().getName() + "取钱1000，余额" + (total -= 1000));
            }
            
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}